
/**
* @Title: ItemCastServiceImpl.java
* @Package com.leetone.service
* @Description: 【】
* @date 2018年3月12日 上午11:44:53
* @version V1.0
* @Company: 上海
* @author:[谭磊][leetone123@163.com]
*/

package com.leetone.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.leetone.mapper.ItemCatMapper;
import com.leetone.pojo.ItemCat;
import com.leetone.pojo.ItemCatExample;
import com.leetone.pojo.ItemCatExample.Criteria;
import com.leetone.vo.EUTreeNode;

/**
* @ClassName: ItemCastServiceImpl
* @Description: 【】
* @date 2018年3月12日 上午11:44:53
* @Company: 上海
* @author:[谭磊][leetone123@163.com]
*/
@Service
public class ItemCastServiceImpl implements ItemCatService {

	@Autowired
	private ItemCatMapper itemCatMapper;
	@Override
	public List<EUTreeNode> getItemCatList(long parentId) {
		ItemCatExample example = new ItemCatExample();
		//设置查询条件,根据父节点查询子节点列表
		Criteria ca = example.createCriteria();
		ca.andParentIdEqualTo(parentId);
		List<ItemCat> list = itemCatMapper.selectByExample(example);
		List<EUTreeNode> result = new ArrayList<>();
		for(ItemCat cat :list)
		{
			EUTreeNode node = new EUTreeNode();
			node.setId(cat.getId());
			node.setText(cat.getName());
			node.setState(cat.getIsParent()?"closed":"open");
			result.add(node);
		}
		return result;
	}

}
